package com.justgame.project.service.system.client;

import com.justgame.project.service.system.entity.SysFileInfo;
import org.springframework.web.bind.annotation.RestController;
import com.justgame.project.service.system.feign.ISysFileInfoClient;
import com.justgame.project.service.system.service.ISysFileInfoService;
import lombok.RequiredArgsConstructor;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 *
 * 系统文件信息存储表远程服务生产者
 *
 * @@tableName sys_file_info
 * @author Zwb
 */
@RestController
@RequiredArgsConstructor
public class SysFileInfoClient implements ISysFileInfoClient{
    private final ISysFileInfoService sysFileInfoService;

    @Override
    public Boolean deleteFile(Set<String> paths) {
        List<SysFileInfo> fileInfos = sysFileInfoService.listByPathIn(paths.toArray(new String[0]));
        return sysFileInfoService.removeBatchByIds(fileInfos.stream().map(SysFileInfo::getId).collect(Collectors.toSet()));
    }
}
